import os
import cv2
from utils.config import *

# 保存视差
def save(disp, img_name):
    # 映射到伪彩色，近红远蓝
    disp_pseudo = cv2.applyColorMap(cv2.convertScaleAbs(disp, alpha=-25), cv2.COLORMAP_JET)

    # 保存预测视差和伪彩色图像
    out_path = os.path.join('./out', dataset)
    if not os.path.exists(os.path.join(out_path, 'pseudo')):
        os.makedirs(os.path.join(out_path, 'pseudo'))
    cv2.imwrite(os.path.join(out_path, img_name), disp)
    cv2.imwrite(os.path.join(out_path, 'pseudo', img_name), disp_pseudo)
